use std::process::Command;

fn test_command() {
    let output = if cfg!(target_os = "windows") {
        Command::new("cmd")
            .args(["/C", "echo hello"])
            .output()
            .expect("failed to execute process")
    } else {
        Command::new("sh")
            .arg("-c")
            .arg("echo hello")
            .output()
            .expect("failed to execute process")
    };
    let hello = output.stdout;
    println!("{:?}", hello);
}

fn test_command_install_name_tool() {
    let output = Command::new("install_name_tool")
        .arg(" -add_rpath /test2/ /Users/asteriskzuo/Tmp/cpp/cmake-examples/01-basic/D-shared-library/build/hello_binary")
        .output()
        .expect("msg: &str");
    println!("cargo:{:?}", output);
}

fn test_command_cd() {
    let output = Command::new("sh")
        .arg("-c")
        .arg(" cd /Users/asteriskzuo/Tmp && mkdir test_rust")
        .output()
        .expect("msg: &str");
    println!("cargo:{:?}", output);
}

fn main() {
    test_command_cd();
    println!("Hello, world!");
}
